package 基础;

import java.io.*;
import java.util.Scanner;
//Scanner的写入
public class Demo_11 {
    public static void main(String[] args) {
        try(OutputStream outputStream = new FileOutputStream("./AAA1.txt",true);
            Scanner scanner = new Scanner(System.in);
            PrintWriter printWriter = new PrintWriter(outputStream)){

            System.out.println("输入（exit）退出：");
            while(scanner.hasNext()){
                String s = scanner.next();

                //增加退出循环的条件
                if(s.equals("exit")){
                    break;
                }
                //先判断在写入
                printWriter.println(s);
            }
        }  catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
